export class HallManager {

    private static _instance: HallManager;

    public static get instance(): HallManager {
        if (!this._instance) {
            this._instance = new HallManager();
        }
        return this._instance;
    }

    public userIdMap: Map<number, string> = new Map();
    public userNameMap: Map<string, number> = new Map();

    public checkUserName(userName: string): boolean {
        return this.userNameMap.has(userName);
    }

    public addUser(userName: string): number{
        if (this.checkUserName(userName)){
            return -1;
        }
        const userId: number = Math.floor(Math.random() * 100000000);
        this.userIdMap.set(userId, userName);
        this.userNameMap.set(userName, userId);
        return userId;
    }
}